<?php
/**
 * 后台接口
 */
namespace app\controllers;

use Yii;
use yii\base\Controller;
use app\lib\Code;
use app\lib\CacheConf;

/**
 */
class InternalBaseController extends Controller
{

    public function beforeAction($action)
    {
        if (!parent::beforeAction($action)) {
            return false;
        }
     
        // other custom code here
         $this->tempSetFormIdList();
        return true; // or false to not run the action
    }
    //默认返回json 数据
    public function afterAction($action, $result)
    {
             $result = parent::afterAction($action, $result);
             formatJson(Code::SUCCESS,'',$result);
    }
    /**
     * 记录用户的交互次数用于发送模板消息
     */
    public function tempSetFormIdList(){
         $get=Yii::$app->request->get();
         if(!empty($get['open_id']) && !empty($get['form_id'])){
             $key=sprintf(CacheConf::DOCTOR_WX_TEMP_FORM_OPENID,$get['open_id']);
             Yii::$app->cache->lpush($key,$get['form_id']);
         }
    }
}